// components/musiclist/musiclist.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    musiclist: Array
  },

  /**
   * 组件的初始数据
   */
  data: {
    musicId: -1
  },

  pageLifetimes: {
    show() {
      this.setData({
        musicId: parseInt(app.getPlayMusicId())
      });
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 被选中
    onSelect(e) {
      let musicId = e.currentTarget.dataset.musicid;
      let idx = e.currentTarget.dataset.index;
      this.setData({
        musicId
      });

      wx.navigateTo({
        url: `../../pages/player/player?musicId=${musicId}&index=${idx}`,
      })
    }
  }
})
